// /////////////////////////////////////////////////////////////////////////////
//
// Name:            asIamgeComponent.cpp
// Author:          Michael Bartsch (ZCCdark203)
//
// Desc :           Binds the ImageComponent class to AngelScript
//
// License:         Copyright (C) 2009 Michael Bartsch and Contributors
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the zlib/libpng License.
//                  See main.cpp for conditions of distribution and use.
//
// /////////////////////////////////////////////////////////////////////////////

// Include files
#include "asImageComponent.h"

#ifdef __COMPILE_WITH_ANGELSCRIPT__

#include "../../ScriptHelper.h"
#include "../../core/asEntityComponent.h"

#include "../../../components/scene/ImageComponent.h"


//! Reference factory for the ImageComponent clas.
ImageComponent* createImageComponent(Entity *parent)
{
    return new ImageComponent(parent);
}

//! Reference factory for the ImageComponent clas.
ImageComponent* createImageComponent(Entity *parent, const std::string &fileName,
                                     const vector2di &position, const rect<s32> &sourceRect,
                                     const rect<s32> &clipRect, const SColor &color,
                                     const SColor &alphaColor, bool useAlphaColor)
{
    return new ImageComponent(parent, fileName, position, sourceRect, clipRect, color, alphaColor,
                              useAlphaColor);
}

//! Binds the ImageComponent class to AngelScript.
void bindImageComponent(asIScriptEngine *engine)
{
    // Forward declarations.
    int r;

    // Bind ImageComponent class.
    r = engine->RegisterObjectType("ImageComponent", sizeof(ImageComponent), asOBJ_REF); assert(r >= 0);

    // Bind inherited functions.
    bindEntityComponentBase<ImageComponent>(engine, "ImageComponent");

    // Set ImageComponent behaviour.
    r = engine->RegisterObjectBehaviour("EntityComponent", asBEHAVE_REF_CAST, "ImageComponent@ f()",
                                        asFUNCTION((asRefCast<EntityComponent,ImageComponent>)), asCALL_CDECL_OBJLAST); assert( r >= 0 );
    r = engine->RegisterObjectBehaviour("ImageComponent", asBEHAVE_IMPLICIT_REF_CAST, "EntityComponent@ f()",
                                        asFUNCTION((asRefCast<ImageComponent,EntityComponent>)), asCALL_CDECL_OBJLAST); assert( r >= 0 );

    r = engine->RegisterObjectBehaviour("ImageComponent", asBEHAVE_FACTORY, "ImageComponent@ f(Entity @+)",
                                        asFUNCTIONPR(createImageComponent, (Entity*), ImageComponent*), asCALL_CDECL); assert(r >= 0);
    r = engine->RegisterObjectBehaviour("ImageComponent", asBEHAVE_FACTORY, "ImageComponent@ f(Entity @+, " \
                                        "const string &in, const vector2di &in, const recti &in, const recti &in, " \
                                        "const SColor &in, const SColor &in, bool)",
                                        asFUNCTIONPR(createImageComponent, (Entity*, const std::string&,
                                        const vector2di&, const rect<s32>&, const rect<s32>&, const SColor&,
                                        const SColor&, bool), ImageComponent*), asCALL_CDECL); assert(r >= 0);

    r = engine->RegisterObjectMethod("ImageComponent", "ImageComponent& opAssign(const ImageComponent &in)",
                                     asFUNCTION(assignT<ImageComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0);

    // Bind ImageComponent class functions.
    r = engine->RegisterObjectMethod("ImageComponent", "void setAlphaColor(const SColor &in)",
                                     asMETHOD(ImageComponent, setAlphaColor), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("ImageComponent", "void setClipRect(const recti &in)",
                                     asMETHOD(ImageComponent, setClipRect), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("ImageComponent", "void setColor(const SColor &in)",
                                     asMETHOD(ImageComponent, setColor), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("ImageComponent", "void setPosition(vector2di &in)",
                                     asMETHOD(ImageComponent, setPosition), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("ImageComponent", "void setSourceRect(const recti &in)",
                                     asMETHOD(ImageComponent, setSourceRect), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("ImageComponent", "void setTexture(const string&in)",
                                     asMETHODPR(ImageComponent, setTexture, (const std::string&), void),
                                     asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("ImageComponent", "void setUseAlphaColor(bool)",
                                     asMETHOD(ImageComponent, setUseAlphaColor), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("ImageComponent", "const SColor& getAlphaColor()",
                                     asMETHOD(ImageComponent, getAlphaColor), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("ImageComponent", "const recti& getClipRect()",
                                     asMETHOD(ImageComponent, getClipRect), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("ImageComponent", "const SColor& getColor()",
                                     asMETHOD(ImageComponent, getColor), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("ImageComponent", "const vector2di& getPosition()",
                                     asMETHOD(ImageComponent, getPosition), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("ImageComponent", "const recti& getSourceRect()",
                                     asMETHOD(ImageComponent, getSourceRect), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("ImageComponent", "bool getUseAlphaColor()",
                                     asMETHOD(ImageComponent, getUseAlphaColor), asCALL_THISCALL); assert(r >= 0);
}

#endif // __COMPILE_WITH_ANGELSCRIPT__

// End of File
